package com.xyd.process.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xyd.common.result.GlobalResultClass;
import com.xyd.model.process.vo.ProcessQueryVO;
import com.xyd.model.process.vo.ProcessVO;
import com.xyd.process.service.ProcessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name =  "审批流管理")
@RestController
@RequestMapping(value = "/admin/process")
@SuppressWarnings({"unchecked", "rawtypes"})
public class ProcessController {
    @Autowired
    private ProcessService processService;

    @PreAuthorize("hasAuthority('bnt.process.list')")
    @Operation(summary = "获取分页列表")
    @GetMapping("{page}/{limit}")
    public GlobalResultClass index(
            @Parameter(name = "page", description = "当前页码", required = true)
            @PathVariable Long page,

            @Parameter(name = "limit", description = "每页记录数", required = true)
            @PathVariable Long limit,

            @Parameter(name = "processQueryVO", description = "查询对象", required = false)
            ProcessQueryVO processQueryVO) {
        Page<ProcessVO> pageParam = new Page<>(page, limit);
        System.out.println("================================processQueryVo==========================================");
        System.out.println(processQueryVO);
        System.out.println(page);
        System.out.println(limit);
        IPage<ProcessVO> pageModel = processService.selectPage(pageParam, processQueryVO);

        return GlobalResultClass.ok(pageModel);
    }
}
